/*
 * 2006-04-18 Li Ximing, Zhang Yanbo - Create.
 */
package com.hd123.rumba.log;

import net.sf.hibernate.HibernateException;

import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.runtime.IAfterSaveNew;
import com.hd123.rumba.runtime.IBeforeRemove;
import com.hd123.rumba.runtime.IBeforeSave;
import com.hd123.rumba.runtime.Manager;
import com.hd123.rumba.runtime.ObserverRegistry;

/**
 * 操作日志 | 管理员 | 实现类
 * 
 * @author lxm
 * @author zhangyanbo
 * 
 */
public abstract class OperateLogMgr extends Manager implements IOperateLogMgr {

  public OperateLogMgr() {
    super();
    this.registryClass("com.hd123.rumba.log.IOperateLog", "com.hd123.rumba.log.OperateLog");
  }

  public void save(IOperateLog log) throws BusinessException, HibernateException {
    this.checkParameterNotNull(log, "log");

    ObserverRegistry.notifyObservers(IBeforeSave.class, log);

    getSession().saveOrUpdate(log);

    ObserverRegistry.notifyObservers(IAfterSaveNew.class, log);
  }

  public void remove(IOperateLog log) throws BusinessException, HibernateException {
    this.checkParameterNotNull(log, "log");

    ObserverRegistry.notifyObservers(IBeforeRemove.class, log);

    getSession().delete(log);
  }

  public IOperateLog getLog(String uuid) throws BusinessException, HibernateException {
    this.checkParameterNotNull(uuid, "uuid");

    return (IOperateLog) getSession().get(IOperateLog.class, uuid);
  }

}
